# -*- coding: utf-8 -*-
# @Author : zhangxuchuo
# @Date   : 2021/8/12
# @File   : Inter111_EntCurrOvduCheck.py
# @E-mail : wangbaoshan@bbdservice.com

'''eof
name:申请企业行内信贷业务存在当前逾期
code:Inter111_EntCurrOvduCheck
tableName:
columnName:
groups:企业通用模块
dependencies:WDXT_CLYW_ENT
type:常用指标
datasourceType:在线指标
description:
eof'''

import sys
import pandas as pd
import json
from datetime import datetime
#从网贷《ratingRequest.abnormalloan》表中取得数据
null_type_list = ['', ' ', None, 'null', 'Null', 'NULL', '/', '-', '--', []]

def isFloat(x):
    '''
    判断x为float类型且大于等于0
    :param x:
    :return:
    '''
    try:
        if isinstance(float(x), float) and float(x) >= 0:
            if str(x) in ['inf', 'infinity', 'INF', 'INFINITY', 'True']:
                return False
            else:
                return True
        else:
            return False
    except:
        return False



def Inter111_EntCurrOvduCheck():
    WDXT = WDXT_CLYW_ENT.get('body')
    abnormalloan = WDXT.get('businessArray')
    if abnormalloan == '' or len(abnormalloan) == 0:
        return 0
    else:
        days = []
        for i in abnormalloan:
            overdueday = i.get('overDueDays', '')
            if isFloat(overdueday):
                if float(overdueday) >= 1:
                    days.append(overdueday)
                else:
                    pass
            else:
                days.append('None')

    if len(list(set(days))) == 1 and list(set(days))[0] == 'None':
        return '缺失值'
    else:
        days = [i for i in days if i != 'None']
        return max(days)

result = Inter111_EntCurrOvduCheck()